﻿package mortal.game.view.funcPreView
{
    import Message.DB.Tables.*;
    import com.gengine.global.*;
    import com.greensock.*;
    import com.mui.controls.*;
    import mortal.game.cache.*;
    import mortal.game.events.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.guide.data.*;
    import mortal.game.view.common.guide.view.*;
    import mortal.game.view.forging.data.*;
    import mortal.game.view.palyer.data.*;
    import mortal.mvc.core.*;

    public class FuncPreviewUtil extends Object
    {
        private var _guideNewFunc:AutoGuideNewFunc;
        private var _guidingData:TSystemTrailer;
        private static var _instance:FuncPreviewUtil;

        public function FuncPreviewUtil()
        {
            return;
        }// end function

        public function checkAndGuide(param1:TSystemTrailer) : void
        {
            if (FuncPreCofonfig.instance.hasGuideSystemInAutoGuide(param1.system))
            {
                return;
            }
            this.guide(param1);
            return;
        }// end function

        public function shouldShowModule() : Boolean
        {
            if (!FuncPreviewModule.hasInstanceShowing())
            {
                return false;
            }
            if (Cache.instance.group.isInGroup)
            {
                if (Cache.instance.group.players != null && Cache.instance.group.players.length > 1)
                {
                    return false;
                }
            }
            return true;
        }// end function

        private function guide(param1:TSystemTrailer) : void
        {
            this._guidingData = param1;
            if (this._guideNewFunc == null)
            {
                this._guideNewFunc = new AutoGuideNewFunc();
            }
            this._guideNewFunc.show();
            var _loc_2:Number = 0.1;
            this._guideNewFunc.scaleY = 0.1;
            this._guideNewFunc.scaleX = _loc_2;
            if (param1 == null)
            {
                Alert.show("TSystemTrailer == null");
            }
            this._guideNewFunc.setLabel(param1.icon1, param1.icon2, "");
            this._guideNewFunc.callback = this.guideEnd;
            this._guideNewFunc.x = 0;
            TweenMax.to(this._guideNewFunc, 0.1, {scaleX:1, scaleY:1, x:Global.stage.stageWidth / 2 - 260});
            return;
        }// end function

        private function guideEnd() : void
        {
            if (this._guidingData == null)
            {
                return;
            }
            if (parseInt(this._guidingData.system) == 121)
            {
                AutoGuideCache.isGuideFuncPanel = true;
            }
            if (parseInt(this._guidingData.system) == 108)
            {
                AutoGuideCache.isGuideFuncPanel = true;
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerModuleShowIndexByType, PlayerConst.TabType_Artifact));
            }
            else if (parseInt(this._guidingData.system) == 109)
            {
                AutoGuideCache.isGuideFuncPanel = true;
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerModuleShowIndexByType, PlayerConst.TabType_Clothes));
            }
            else if (parseInt(this._guidingData.system) == 112)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.OpenForgingPanel, ForgingConst.Page_GemStrengthen));
            }
            else if (parseInt(this._guidingData.system) == 122)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerModuleShowIndexByType, PlayerConst.TabType_FightSoul));
            }
            else if (parseInt(this._guidingData.system) == 123)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerModuleShowIndexByType, PlayerConst.TabType_FightMethod));
            }
            else if (parseInt(this._guidingData.system) == 124)
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.PlayerModuleShowIndexByType, PlayerConst.TabType_DragonSoul));
            }
            return;
        }// end function

        public static function get instance() : FuncPreviewUtil
        {
            if (_instance == null)
            {
                _instance = new FuncPreviewUtil;
            }
            return _instance;
        }// end function

    }
}
